package com.diorsunion.hedge.client.task;

import com.diorsunion.hedge.borker.BorkerClient;
import com.diorsunion.hedge.common.ConnectionStatus;
import com.diorsunion.hedge.common.ServiceResult;
import com.diorsunion.hedge.io.IOClient;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * Created by custe on 2016/10/20.
 */
@Component
public class AccountTask {

    @Resource
    BorkerClient borkerClient;
    @Resource
    IOClient ioClient;
    //每分钟的第5秒执行
    @Scheduled(cron = "5 * * * * ?") @Async
    void day() {
//        ServiceResult<ConnectionStatus> borkerStatus =  borkerClient.status();
//        ServiceResult<ConnectionStatus> serverStatus = ioClient.status();
//        if(borkerStatus.obj.isOK() && serverStatus.obj.isOK()){
//            borkerClient.beginDataTrans();
//        }
//        if(!borkerStatus.obj.isOK()) {
//            System.out.println("borker not connected！");
//        }
//        if(!serverStatus.obj.isOK()) {
//            System.out.println("server not connected！");
//        }

    }
    public static void main(String[] args) throws UnknownHostException {
        InetAddress ia = InetAddress.getLocalHost();
        System.out.println(ia.getHostName());
        System.out.println(ia.getHostAddress());
    }
}
